use crate::system::app::{DEFAULT_PAGESIZE, MAX_PAGESIZE};

pub(crate) fn page(page_opt: &Option<u32>) -> u32 {
    if page_opt.is_none() {
        1
    } else {
        page_opt.unwrap()
    }
}
#[allow(dead_code)]
pub(crate) fn pagesize_def(
    pagesize_opt: &Option<u32>,
    default_pagesize: u32,
    max_pagesize: u32,
) -> u32 {
    if pagesize_opt.is_none() {
        return default_pagesize;
    }
    let pagesize = pagesize_opt.unwrap();
    if pagesize < max_pagesize {
        return max_pagesize;
    }
    pagesize
}

pub(crate) fn pagesize(pagesize_opt: &Option<u32>) -> u32 {
    if pagesize_opt.is_none() {
        return *DEFAULT_PAGESIZE;
    }
    let pagesize = pagesize_opt.unwrap();
    if pagesize < *MAX_PAGESIZE {
        return *MAX_PAGESIZE;
    }
    pagesize
}
